package com.fanhao.dllo.soundfm.activity;

import android.content.Intent;
import android.view.View;
import android.webkit.WebView;
import android.widget.ImageView;
import android.widget.TextView;

import com.fanhao.dllo.soundfm.R;

/**
 * Created by dllo on 16/1/18.
 * 点击轮播进入的广告界面
 */
public class AdverActivity extends BaseActivity {
    private WebView webViewAvder;
    private String Url;
    private String activityUrl;
    private String FinalUrl;
    private ImageView backAdverIv;
    private TextView titleAdverTv;
    private String title;

    @Override
    protected int setLayout() {
        return R.layout.activity_adver;
    }

    @Override
    protected void initView() {
        Intent intent = getIntent();
        Url = intent.getStringExtra("url");
        activityUrl = "http://activity.ximalaya.com/activity-web/activity/"+intent.getStringExtra("activityId")+"?app=iting&version=4.3.44";

        title = intent.getStringExtra("shortTitle");
        webViewAvder = findView(R.id.webView_adver);
        //加载的网页链接可以点击并跳转，但是按钮点了却没反应
        //添加下面一行代码以便响应JS控件
        webViewAvder.getSettings().setJavaScriptEnabled(true);

        if (Url == null) {
            FinalUrl = activityUrl;
        } else {
            FinalUrl = Url;
        }
        webViewAvder.loadUrl(FinalUrl);
        backAdverIv = findView(R.id.ivBack_webViewAdver);
        titleAdverTv = findView(R.id.tvTitle_webViewAdver);
        titleAdverTv.setText(title);

        backAdverIv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
                overridePendingTransition(R.anim.no_move, R.anim.move_out_from_bottom);
            }
        });

    }

}
